@extends('home.layout.base')
<link rel="stylesheet" href="{{URL::asset('./css/suppliermy/examine.css')}}">
@section('content')
<div class="mainHrContent" id="hrcustomer_service">
    <div class="storelistTitle" id="storelistTitle"  v-cloak>
        <span class="storelistTitle_left">
            <span>
                <img src="{{URL::asset('./img/icon/home.png')}}">
            </span>
            <span><a href="{{route('home.index.index') }}">首页</a> >
                <a href="{{route('home.suppliermy.supplierIndex') }}">供应商中心</a>
                <!-- suppliermy.supplierIndex -->
            </span>
        </span>
        <!-- <span class="storelistTitle_right">
            <span>找不到合适的供应商？发个需求试试？</span>
            <button @click="window.location.href ='{{ route('home.demand.demandAdd')}}'">免费发布需求</button>
        </span> -->
    </div>
    <div class="hrContent">
        @include('home.suppliermy.menu')
        <div class="basicInfo" id="hrcustomer_services"  v-cloak>
            <div class="audit" v-if="detailsData.status==1">
                <img src="{{URL::asset('./img/icon/audit.png')}}">
                <span>

                    账号注册资料认证审核中，
                    <a>
                        3天
                    </a>

                    内完成审核流程，请3天后登录查看审核状态

                </span>
            </div>
            <div class="unaudit" v-if="detailsData.status==0">
                <img style="width:210px;" src="{{URL::asset('./img/icon/audit2.png')}}">
                <span>
                    对不起，您提交的
                    <a>
                        《公司具体资料》
                    </a>
                    认证资料未通过审核，请重新提交认证，
                    如
                    <a>
                        七天内
                    </a>
                    未提交新的认证资料，我们将删除您的账号！
                </span>
                <button @click="dialogVisible=true">
                    上传认证资料
                </button>
            </div>
            <el-dialog :visible.sync="dialogVisible" width="508px" :before-close="handleClose">
                <div class="basicInfo_title">
                    <span></span>
                    上传认证资料
                    <a class="dialogFalse" @click="dialogVisible=false">×</a>
                </div>
                <div class="dialogMain">
                    <el-upload class="upload-demo" :action="uploadUrl" :on-remove="handleRemove" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload" :file-list="fileList3">
                        <div class="dialogUpload">
                            <div>
                                <img src="{{URL::asset('./img/icon/dialogUpload.png')}}">

                            </div>
                            <span>文件需为：
                                pdf格式</span>
                        </div>
                    </el-upload>
                </div>
                <button class="dialogButton" @click="submit">
                    确定上传
                </button>
            </el-dialog>
        </div>
    </div>

</div>
<style>
    .el-dialog__header {
        display: none;
    }

    .basicInfo_title {
        position: relative;
    }

    .dialogFalse {
        display: inline-block;
        position: absolute;
        cursor: pointer;
        width: 20px;
        height: 20px;
        font-size: 20px;
        font-family: Source Han Sans CN;
        font-weight: 100;
        color: rgba(102, 102, 102, 1);
        right: 0px;
        top: -5px;
    }
</style>
@endsection
@section('compontentScipts')
<script>
    $(() => {
        let hrcustomer_service = new Vue({
            el: '#hrcustomer_services',
            data: () => {
                return {
                    uploadUrl: UPLOAD_FILE,
                    dialogVisible: false,
                    detailsData: {},
                    fileList3: []
                }
            },
            created() {
                this.getData();
            },
            mounted() {},
            methods: {
                getData() {
                    this.dialogVisible = false;
                    let data = {};
                    apiAjax("{{ route('home.user.supplierExamineApi')}}", 'get', data, (res) => {
                        if (res.code == 0) {
                            this.detailsData = res.data;
                        } else {
                            this.$message({
                                message: res.msg,
                                type: 'warning'
                            });
                        }
                    }, (erro) => {

                    });
                },
                handleClose(done) {
                    this.dialogVisible = false;
                },
                beforeAvatarUpload(file) {
                    const type = file.name.split('.')[1];
                    const isJPG = type == 'pdf';
                    // const isJPG = file.type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
                    //     file.type == 'pdf';

                    if (!isJPG) {
                        this.$message.error('上传文件只能是PDF!');
                    }
                    return isJPG;
                },
                handleAvatarSuccess(res, file) {
                    this.fileList3.push(res.data.path)
                },
                handleRemove(file, fileList) {
                    this.fileList3 = [];
                    fileList.forEach(element => {
                        this.fileList3.push(element.response.data.path)
                    });
                },
                submit() {
                    let data = {
                        certification: this.fileList3.join()
                    }
                    apiAjax("{{ route('home.user.supplierUploadDataApi')}}", 'post', data, (res) => {
                        if (res.code == 0) {
                            this.$message({
                                message: res.msg,
                                type: 'success'
                            });
                            this.getData();
                        } else {
                            this.$message({
                                message: res.msg,
                                type: 'warning'
                            });
                        }
                    }, (erro) => {

                    });
                },
            }
        })
    })
</script>
@endsection